/*
 * Class PublicChat
 *
 * Version 1.0
 *
 * Sunday, August 17, 2008
 *
 * Created by Palidino76
 */

package palidino76.rs2.io.packets;

import palidino76.rs2.players.Player;
import palidino76.rs2.util.Misc;

public class PublicChat implements Packet {
    /**
     * Handles player chatting.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        p.chatTextEffects = p.stream.readUnsignedWord();
        int numChars = p.stream.readUnsignedByte();
        p.chatText = Misc.decryptPlayerChat(p.stream, numChars);
        p.chatTextUpdateReq = true;
        p.updateReq = true;
        //Misc.appendData("ChatLogs/" + p.username + ".txt", "[" + Misc.getDate() + "] " + p.username + ": " + p.chatText);
    }
}
